package com.jiwei.system.vo;

import com.jiwei.system.pojo.MemberLogin;
import org.apache.commons.codec.digest.DigestUtils;

import java.io.Serializable;
import java.util.Objects;

/**
 * @title: UserLogin
 * @Author 赖志宇
 * @Description
 * @Date: 2020/8/14
 * @Version 1.0
 */
public class Login implements Serializable, VO<MemberLogin> {
    // @Length(min=11,max = 11,message = "手机号码长度不为11位")
    private String account;
    // @Length(min=6,max = 6,message = "验证码长度不为6位")
    private String password;

    public Login(String account, String password) {
        this.account = account;
        this.password = password;
    }

    public Login() {
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Login)) return false;
        Login login = (Login) o;
        return getAccount().equals(login.getAccount()) &&
                getPassword().equals(login.getPassword());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getAccount(), getPassword());
    }

    @Override
    public String toString() {
        return "Login{" +
                "account='" + account + '\'' +
                ", password='" + password + '\'' +
                '}';
    }


    @Override
    public MemberLogin changeToPo() {
        return new MemberLogin(account, DigestUtils.md5Hex(password),null);
    }
}
